<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\App;

class TypeResource extends JsonResource
{
  protected $formats;

  public function toArray($request)
  {
    $this->formats = config('coreapi.' . App::getLocale());

    return [
      'id' => $this->id,
      'type' => $this->type,
      'active' => $this->active,
      'created_at' => localizedFormat($this->created_at, 'datetime'),
      'updated_at' => localizedFormat($this->updated_at, 'datetime'),
      // 'addresses' => AddressResource::collection($this->whenLoaded('addresses')),
      // 'telephones' => AddressResource::collection($this->whenLoaded('telephones')),
      // 'emails' => EmailResource::collection($this->whenLoaded('emails')),
      // 'catalog' => new CatalogResource($this->whenLoaded('catalog')),
    ];
  }
}
